import 'package:flutter/cupertino.dart';
import 'package:lib_wallet_connect/utils/web_wallet_service.dart';

import '../../kai_print.dart';
import '../bridge/native_channel_bridge.dart';

class WCProviderNotifier extends WCServiceWidget with ChangeNotifier  {

  WCProviderNotifier(){
    try{
    }catch(e){
      kaiPrint('init error $e');
    }
  }


  initProvider(String url) async {
    try{
      kaiPrint('widget.getWeb3Wallet() ${getWeb3Wallet}');
      if(getWeb3Wallet==null){
        await createWcc();
      }
      final Uri uriData = Uri.parse(url);
      kaiPrint('uriData $uriData');
      await getWeb3Wallet!.pair(uri: uriData);
      NativeChannelBridge.instance.flutterShowDialog(num: 1);
    }catch(e){
      kaiPrint('error $e');
    }
  }
  // void onSessionProposal(SessionProposalEvent? args) async {
  //   print('yanzheng');
  // }
  //
  // void onPairingInvalid(PairingInvalidEvent? args) {
  //   debugPrint('[$runtimeType] _onPairingInvalid $args');
  // }
  //
  // void onPairingCreate(PairingEvent? args) {
  //   debugPrint('[$runtimeType] _onPairingCreate $args');
  // }
  //
  // void onSessionRequest(SessionRequestEvent? args) async {}

  // personal_sign is handled using onSessionRequest event for demo purposes
  Future<void> personalSign(String topic, dynamic parameters) async {
    debugPrint('[$runtimeType] personalSign request: $parameters');
  }

  Future<void> ethSign(String topic, dynamic parameters) async {
    debugPrint('[$runtimeType] ethSign request: $parameters');
  }

  Future<void> ethSignTypedData(String topic, dynamic parameters) async {
    debugPrint('[$runtimeType] ethSignTypedData request: $parameters');
  }

  Future<void> ethSignTypedDataV4(String topic, dynamic parameters) async {
    debugPrint('[$runtimeType] ethSignTypedDataV4 request: $parameters');
  }

  Future<void> ethSignTransaction(String topic, dynamic parameters) async {
    debugPrint('[$runtimeType] ethSignTransaction request: $parameters');
  }

  Future<void> ethSendTransaction(String topic, dynamic parameters) async {
    debugPrint('[$runtimeType] ethSendTransaction request: $parameters');
  }

  Future<void> switchChain(String topic, dynamic parameters) async {
    debugPrint('received switchChain request: $topic $parameters');
  }

  Future<void> addChain(String topic, dynamic parameters) async {
    debugPrint('received addChain request: $topic $parameters');
  }
}